<?php
/**
 * URL related utilities 
 * 
 * @author Mitchelle Pascual <mitch.pascual@gmail.com>
 * $date 04/01/2010
 */
class Owg_Utility_Url
{
	
	/**
	 * Get current url w/ an option to remove parameters
	 * eg. Owg_Utility_Url::url('page');
	 */
	public static function url()
	{
		$url = '';
		$front = Zend_Controller_Front::getInstance();
		$baseUrl = $front->getRequest()->getBaseUrl();
		$controller = $front->getRequest()->getControllerName();
		$action = $front->getRequest()->getActionName();
		$module = $front->getRequest()->getModuleName();
		
		$params = $front->getRequest()->getParams();
		unset($params['module'], $params['controller'], $params['action']);

		foreach (func_get_args() as $key)
		{
			unset($params[$key]);
		}
		
		if ($module != 'default') // we don't want this in the url
		{
			$url = $baseUrl . '/' . $module . '/' . $controller . '/' . $action;
		} 
		else
		{
			$url = $baseUrl . '/' . $controller . '/' . $action;
		}		
		
		foreach ($params as $k => $v)
		{
			$url .= '/' . $k . '/' . $v; 
		}		
		
		return $url;
	}
	
	
	
}